Class BipartiteCondition


  • public class BipartiteCondition
    extends Condition
    Represents a bipartite graph as a Condition object. Used to test for bipartiteness.
    Version:
    1.1.1 May 26, 2015
    Author:
    Charles Allen Schultz II
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean satisfies​(Graph existingGraph)
      Used to test if the supplied graph is within the bounds of the condition's implementation.
      private boolean satisfies​(Graph existingGraph, java.util.Set<Node> addSet, java.util.Set<Node> compareSet, Node current)
      Private method for stepping through the adjacency lists and determining if the graph is bipartite.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BipartiteCondition

        public BipartiteCondition()
    • Method Detail

      • satisfies

        public boolean satisfies​(Graph existingGraph)
        Used to test if the supplied graph is within the bounds of the condition's implementation.

        Checks to determine if the supplied graph is Bipartite.

        Specified by:
        satisfies in class Condition
        Parameters:
        existingGraph - the Graph to test if the Condition applies.
        Returns:
        true if the graph is bipartite.
      • satisfies

        private boolean satisfies​(Graph existingGraph,
                                  java.util.Set<Node> addSet,
                                  java.util.Set<Node> compareSet,
                                  Node current)
        Private method for stepping through the adjacency lists and determining if the graph is bipartite. Specifically, it uses a Depth-First model for exploring the node tree and sorting the nodes into two groups. If it successfully sorts the nodes into two groups with no invalidating edges, it returns true.
        Parameters:
        existingGraph - the Graph object to test against.
        addSet - the current set to add a node to based on the previous.
        compareSet - the current set to add adjacent nodes to.
        current - the current Node being compared.
        Returns:
        true if the structure could be bipartite.